<?php
include_once($_SERVER['DOCUMENT_ROOT'].'/LLKH/Models/Hethong.php');
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
     $host = "localhost";
     $user = "root"; 
     $pass = "";
     $dbname = "llkh";
     
if ($_SERVER['REQUEST_METHOD'] == 'POST') { 
    if (isset($_POST['btn_im'])){
        $filename = $_POST['dir'];
        $im = new Hethong();
        $im->setHost($host);
        $im->setUser($user);
        $im->setPass($pass);
        $im->setBDname($dbname);
        $im->setFilename($filename);
        $im->import_database();
    }
    if (isset($_POST['btn_ex'])){
        //ob_start(); 
        $ex = new Hethong();
        $ex->setHost($host);
        $ex->setUser($user);
        $ex->setPass($pass);
        $ex->setBDname($dbname);
        $ex->export_database();
        $filename_dl = mysql_real_escape_string($ex->getFilename());

        $download_link = '../LLKH/'.$filename_dl.'';
      
        echo '
            <script>
            var myWindow;
            function newpage()
            {
            myWindow = window.open("'.$download_link.'","","width=100,height=100");
            myWindow.focus(); 
            }
            setTimeout("newpage()",100); //
            </script>
        ';
    }

    if(isset($_POST['btn_ex'])){
        $ex = new Hethong();
        $ex->setHost($host);
        $ex->setUser($user);
        $ex->setPass($pass);
        $ex->setBDname($dbname);
        $ex->export_database();
    }
}

include('Views/Hethong.php');
?>
